﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using X.Web;
using X.Entity;
using System.Web.UI.HtmlControls;

namespace X.WebSite.Product
{
    public partial class Compare : PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string p1 = string.Empty, p2 = string.Empty;

                if (!string.IsNullOrEmpty(Request.QueryString["p1"]))
                    p1 = Request.QueryString["p1"];

                if (!string.IsNullOrEmpty(Request.QueryString["p2"]))
                    p2 = Request.QueryString["p2"];

                int id1 = 0;
                int id2 = 0;

                p1 = X.Common.StringUtils.UrlToString(p1, ref id1);
                p2 = X.Common.StringUtils.UrlToString(p2, ref id2);

                ProductInfo productInfo1;
                ProductInfo productInfo2;

                if (0 != id1)
                    productInfo1 = Bll.Product.GetProduct(id1);
                else
                    productInfo1 = Bll.Product.GetProduct(p1);

                if (0 != id2)
                    productInfo2 = Bll.Product.GetProduct(id2);
                else
                    productInfo2 = Bll.Product.GetProduct(p2);

                Title = productInfo1.ProductName + " vs " + productInfo2.ProductName;

                this.lblProductName1.Text = productInfo1.ProductName;
                this.lblCategoryName1.Text = productInfo1.CategoryName;
                this.lblPrice1.Text = productInfo1.Price.ToString();
                this.lblDescription1.Text = productInfo1.ProductDescribe;

                this.lblProductName2.Text = productInfo2.ProductName;
                this.lblCategoryName2.Text = productInfo2.CategoryName;
                this.lblPrice2.Text = productInfo2.Price.ToString();
                this.lblDescription2.Text = productInfo2.ProductDescribe;
            }
        }

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            //Keywords
            HtmlMeta keywords = new HtmlMeta();
            keywords.Name = "keywords";
            keywords.Content = SiteInfoConfig.SiteKeyword;
            Header.Controls.Add(keywords);

            //Description
            HtmlMeta description = new HtmlMeta();
            description.Name = "description";
            description.Content = SiteInfoConfig.SiteDescription;
            Header.Controls.Add(description);
        }
    }
}